package com.design.graduation.asdemo.utils;

import com.alibaba.fastjson.JSON;

import java.util.List;

/**
 * @author by weijianxing on 11/1/15.
 *         <p/>
 *         封装JSON的操作
 *         <p/>
 *         优点:如果想更换JSON的库的话,只需要修改这个类就可以了
 */
public class JSONUtil {

    public static <T> List<T> stringToList(String jsonString, Class<T> clazz) {
        return JSON.parseArray(jsonString, clazz);
    }

    public static <T> T stringToObject(String jsonString, Class<T> clazz) {
        return JSON.parseObject(jsonString, clazz);
    }

    public static String toJSONString(Object object) {
        return JSON.toJSONString(object);
    }
}
